import { INCREMENTCOUNT, DECREMENTCOUNT } from '../constant/countconst'
const init = { count: 0 }

export default function countReducer(prevState = init, action) {
  const { type, data } = action

  switch (type) {
    case INCREMENTCOUNT:
      return { ...init, count: prevState.count + data }
    case DECREMENTCOUNT:
      return { ...init, count: prevState.count - data }
  };
  return prevState
}

